package com.fzg.common.demo.hutool;

import cn.hutool.core.lang.Console;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.lang.ObjectId;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.thread.ConcurrencyTester;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.*;
import lombok.extern.slf4j.Slf4j;

/**
 * create by fzg
 * 2022/12/13 11:57
 */

@Slf4j
public class Demo07 {

    public static void main(String[] args) {
        String s = IdUtil.randomUUID();
        log.info(s);
        String s1 = IdUtil.simpleUUID();
        log.info(s1);

        String next = ObjectId.next();
        log.info(next);

        String s2 = IdUtil.objectId();
        log.info(s2);

        Snowflake snowflake = IdUtil.getSnowflake();
        long l = snowflake.nextId();
        log.info(l + "");

        Snowflake snowflake1 = IdUtil.getSnowflake(1, 1);
        long l1 = snowflake1.nextId();
        log.info(l1 + "");

        String s3 = snowflake.nextIdStr();
        log.info(s3);

        log.info("##############################");
        boolean validCard18 = IdcardUtil.isValidCard18("532128199811292333");
        log.info(validCard18 + "");

        int ageByIdCard = IdcardUtil.getAgeByIdCard("532128199811292333");
        log.info(ageByIdCard + "");

        String birth = IdcardUtil.getBirth("532128199811292333");
        String birthByIdCard = IdcardUtil.getBirthByIdCard("532128199811292333");
        log.info(birth);
        log.info(birthByIdCard);

        String provinceByIdCard = IdcardUtil.getProvinceByIdCard("532128199811292333");
        String provinceCodeByIdCard = IdcardUtil.getProvinceCodeByIdCard("532128199811292333");
        log.info(provinceByIdCard);
        log.info(provinceCodeByIdCard);


        log.info("#################################");
        String s4 = DesensitizedUtil.idCardNum("532128199811292333", 6, 4);
        log.info(s4);

        Long aLong = DesensitizedUtil.userId();
        log.info(aLong + "");

        String chineseName = DesensitizedUtil.chineseName("范占国");
        log.info(chineseName);

        String password = DesensitizedUtil.password("12389");
        log.info(password);

        String s5 = DesensitizedUtil.mobilePhone("18387008391");
        log.info(s5);

        String address = DesensitizedUtil.address("云南省昭通市镇雄县以勒镇", 5);
        log.info(address);

        String email = DesensitizedUtil.email("1840633803@qq.com");
        log.info(email);

        String card = DesensitizedUtil.carLicense("云A2333s");
        log.info(card);

        String s6 = CreditCodeUtil.randomCreditCode();
        log.info(s6);

        Dict set = Dict.create().set("a1", "fzg").set("a2", 1).set("a3", 2.39);
        Object a1 = set.get("a3");
        log.info(a1.toString());
        String a2 = set.getStr("a1");
        log.info(a2);

        ConcurrencyTester tester = ThreadUtil.concurrencyTest(10, () -> {
            // 测试的逻辑内容
            long delay = RandomUtil.randomLong(100, 1000);
            ThreadUtil.sleep(delay);
            Console.log("{} test finished, delay: {}", Thread.currentThread().getName(), delay);
        });

        // 获取总的执行时间，单位毫秒
        Console.log(tester.getInterval());
    }

}
